#!/bin/sh
#
# This is the script for generating files for a specific Dalton test job.
#
# For the .check file ksh or bash is preferred, otherwise use sh
# (and hope it is not the old Bourne shell, which will not work)
#
if [ -x /bin/ksh ]; then
   CHECK_SHELL='#!/bin/ksh'
elif [ -x /bin/bash ]; then
   CHECK_SHELL='#!/bin/bash'
else
   CHECK_SHELL='#!/bin/sh'
fi


#######################################################################
#  TEST DESCRIPTION
#######################################################################
cat > r12_loc.info <<'%EOF%'
   r12_loc
   --------------
   Molecule:         Methane (CH4)
   Wave Function:    Local-MP2-R12 / 6-311G
   Test Purpose:     Check LMP2-R12/B method with auxiliary basis and
                     a Slater-type geminal (STG) with exponent 0.5.
                     The hybrid and CABS approaches are used. 
                     Linear dependencies were introduced into the 
                     orbital and auxiliary basis sets on purpose. 

                     Note that on 19-Aug-2005 this test failed with ERI! 

                     (It only succeeds with the .HERDIR keyword. The bug 
                     needs be located and fixed. It may be related to
                     linear dependencies within a general contraction.)
%EOF%

#######################################################################
#  MOLECULE INPUT
#######################################################################
cat > r12_loc.mol <<'%EOF%'
# DALTON.BAS with INTGRL directive created 18Aug05  18:24:22
# Directive in input mol file was:
# > BASIS                                                                       
# > 6-311G Turbomole-TZVPP                                                      
INTGRL
CH4: Local MP2-R12 (Ansatz 1)                                                   
                                                                                
    4  0 0            0.10D-14
 1      6.    1    2    1    1
C        1.0900000000000    -0.1200000000000     7.2890100000000
H  11    4
     4563.2400000000        0.0019666500        0.0000000000        0.0000000000
                            0.0000000000
      682.0240000000        0.0152306000        0.0000000000        0.0000000000
                            0.0000000000
      154.9730000000        0.0761269000        0.0000000000        0.0000000000
                            0.0000000000
       44.4553000000        0.2608010000        0.0000000000        0.0000000000
                            0.0000000000
       13.0290000000        0.6164620000        0.0000000000        0.0000000000
                            0.0000000000
        1.8277300000        0.2210060000        0.0000000000        0.0000000000
                            0.0000000000
       20.9642000000        0.0000000000        0.1146600000        0.0000000000
                            0.0000000000
        4.8033100000        0.0000000000        0.9199990000        0.0000000000
                            0.0000000000
        1.4593300000        0.0000000000       -0.0030306800        0.0000000000
                            0.0000000000
        0.4834560000        0.0000000000        0.0000000000        1.0000000000
                            0.0000000000
        0.1455850000        0.0000000000        0.0000000000        0.0000000000
                            1.0000000000
H   5    4
       20.9642000000        0.0402487000        0.0000000000        0.0000000000
                            0.0000000000
        4.8033100000        0.2375940000        0.0000000000        0.0000000000
                            0.0000000000
        1.4593300000        0.8158540000        0.0000000000        0.0000000000
                            0.0000000000
        0.4834560000        0.0000000000        1.0000000000        0.0000000000
                            0.0000000000
        0.1455850000        0.0000000000        0.0000000000        1.0000000000
                            1.0000000000
 1      1.    4    1    1
H        2.8715308320486     0.1736528344531     8.5657410000000
H       -0.6915308320486    -0.4136528344531     8.5657410000000
H        0.7963471655469     1.6615308320486     6.0122790000000
H        1.3836528344531    -1.9015308320486     6.0122790000000
H   5    3
       33.8650000000        0.0254938000        0.0000000000        0.0000000000
        5.0947900000        0.1903730000        0.0000000000        0.0000000000
        1.1587900000        0.8521610000        0.0000000000        0.0000000000
        0.3258400000        0.0000000000        1.0000000000        0.0000000000
        0.1027410000        0.0000000000        0.0000000000        1.0000000000
 2      0.    1    4    1    1    1    1
C        1.0900000000000    -0.1200000000000     7.2890100000000
H  11    5
    13575.3496800000        0.0002224600        0.0000000000        0.0000000000
                            0.0000000000        0.0000000000
     2035.2333680000        0.0017232700        0.0000000000        0.0000000000
                            0.0000000000        0.0000000000
      463.2256236000        0.0089255700        0.0000000000        0.0000000000
                            0.0000000000        0.0000000000
      131.2001960000        0.0357279800        0.0000000000        0.0000000000
                            0.0000000000        0.0000000000
       42.8530158900        0.1107626000        0.0000000000        0.0000000000
                            0.0000000000        0.0000000000
       15.5841857700        0.2429562800        0.0000000000        0.0000000000
                            0.0000000000        0.0000000000
        6.2067138500        0.0000000000        0.4144026300        0.0000000000
                            0.0000000000        0.0000000000
        2.5764896500        0.0000000000        0.2374496900        0.0000000000
                            0.0000000000        0.0000000000
        0.5769633900        0.0000000000        0.0000000000        1.0000000000
                            0.0000000000        0.0000000000
        0.2297283100        0.0000000000        0.0000000000        0.0000000000
                            1.0000000000        0.0000000000
        0.0951644400        0.0000000000        0.0000000000        0.0000000000
                            0.0000000000        1.0000000000
H   6    3
       34.6972322400        0.0053333700        0.0000000000        0.0000000000
        7.9582622800        0.0358641100        0.0000000000        0.0000000000
        2.3780826900        0.1421587300        0.0000000000        0.0000000000
        0.8143320800        0.3427047200        0.0000000000        0.0000000000
        0.2888754700        0.0000000000        1.0000000000        0.0000000000
        0.1005682400        0.0000000000        0.0000000000        1.0000000000
H   2    2
        1.0970000000        1.0000000000        0.0000000000
        0.3180000000        0.0000000000        1.0000000000
H   1    1
        0.7610000000        1.0000000000
 2      0.    4    3    1    1    1
H        2.8715308320486     0.1736528344531     8.5657410000000
H       -0.6915308320486    -0.4136528344531     8.5657410000000
H        0.7963471655469     1.6615308320486     6.0122790000000
H        1.3836528344531    -1.9015308320486     6.0122790000000
H   5    3
       34.0613410000        0.0060252000        0.0000000000        0.0000000000
        5.1235746000        0.0450210900        0.0000000000        0.0000000000
        1.1646626000        0.2018972600        0.0000000000        0.0000000000
        0.3272304000        0.0000000000        1.0000000000        0.0000000000
        0.1030724000        0.0000000000        0.0000000000        1.0000000000
H   2    2
        1.4070000000        1.0000000000        0.0000000000
        0.3880000000        0.0000000000        1.0000000000
H   2    2
        1.0570000000        1.0000000000        0.0000000000
        1.0570000000        0.0000000000        1.0000000000
%EOF%

#######################################################################
#  DALTON INPUT
#######################################################################
cat > r12_loc.dal <<'%EOF%'
**DALTON INPUT
.RUN WAVE FUNCTION
.DIRECT
*MOLBAS
.R12AUX
**INTEGRALS
.R12STG
0.5
3
.DIPLEN
**WAVE FUNCTIONS
.HF
.CC
*SCF INPUT
.THRESH
 1D-10
.DOUBLY OCCUPIED
 5
*ORBITAL INPUT
.MOSTART
 H1DIAG
.LOCALI
 BOYLOC
.FROZEN
 1
*CC INPUT
.HERDIR
.MP2
.PRINT
 3
*R12 INPUT
.CABS
.R12XXL
.NO 2
.NO 3
**END OF DALTON INPUT
%EOF%

#######################################################################

 

#######################################################################

#######################################################################
#  CHECK SCRIPT
#######################################################################
echo $CHECK_SHELL >r12_loc.check
cat >>r12_loc.check <<'%EOF%'
log=$1

if [ `uname` = Linux ]; then
   GREP="egrep -a"
else
   GREP="egrep"
fi

if $GREP -q "not implemented for parallel calculations" $log; then
   echo "TEST ENDED AS EXPECTED"
   exit 0
fi

#
# ! Original MP2-R12 method !
# Noninvariant MP2-R12/0   correlation energy =    0.176293571
# Noninvariant MP2-R12/A   correlation energy =   -0.367036423
#              MP2-R12/A   correlation energy =   -0.370487621
#              MP2-R12/A'  correlation energy =   -0.369767358
# Noninvariant MP2-R12/B   correlation energy =   -0.270519057
#              MP2-R12/B   correlation energy =   -0.271114602
# ! Auxiliary-basis MP2-R12 method !
# Noninvariant MP2-R12/0   correlation energy =    0.008260916
# Noninvariant MP2-R12/A   correlation energy =   -0.193772509
#              MP2-R12/A   correlation energy =   -0.195245122
#              MP2-R12/A'  correlation energy =   -0.194463532
# Noninvariant MP2-R12/B   correlation energy =   -0.173021379
#              MP2-R12/B   correlation energy =   -0.173373550
#
CRIT1=`$GREP "MP2-R12/B   correlation energy =   (-0| -)\.17337355" $log | wc -l`
TEST[1]=`expr	$CRIT1`
CTRL[1]=1
ERROR[1]="LMP2-R12/B ENERGY NOT CORRECT"

PASSED=1
for i in 1 
do 
   if [ ${TEST[i]} -ne ${CTRL[i]} ]; then
     echo "${ERROR[i]} ( test = ${TEST[i]}; control = ${CTRL[i]} ); "
     PASSED=0
   fi
done 

if [ $PASSED -eq 1 ]
then
  echo TEST ENDED PROPERLY
  exit 0
else
  echo THERE IS A PROBLEM 
  exit 1
fi

%EOF%
#######################################################################
